#include "mario.h"
#include "game.h"
#include "gamestate.h"
#include "player.h"
#include <winalleg.h>

Game* Game::GetInstance()
{
    static Game instance;
    return &instance;
}

void Game::Initialize()
{
    _isRunning = true;
}


void Game::Quit()
{
    _isRunning = false;
}


void Game::Update()
{
    // Odswiez aktualny stan gry lub zamknij gre jesli go nie ma.
    GameState* currentGameState = GetCurrentGameState();
    if (currentGameState == NULL)
    {
        Quit();
    }
    else
    {
        currentGameState->Update();
    }	

}


bool Game::IsRunning()
{
    return _isRunning;
}


void Game::PushGameState(GameState* gameState)
{
    _gameStates.push(gameState);
}

void Game::SwitchLastGameState(GameState* gameState)
{
	_gameStates.pop();
    _gameStates.push(gameState);
}


void Game::PopGameState()
{
    if (!_gameStates.empty())
    {
        _gameStates.pop();
    }
}


GameState* Game::GetCurrentGameState()
{
    if (_gameStates.empty())
    {
        return NULL;
    }
    else
    {
        return _gameStates.top();
    }
}
void Game::CreatePlayer()
{
	//player = new Player("Player1",3);
}
